package net.esj.basic.expression.condition.logic;

import net.esj.basic.expression.ExpressionException;
import net.esj.basic.expression.condition.Condition;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Scope("prototype")
@Component("andCondition")
public class ConditionLogicAnd extends  AbstractConditionLogic {


	
	
	public ConditionLogicAnd() {
		super();
	}
	
	@Override
	public boolean passed(Number num) throws ExpressionException {
		String msg = "";
		boolean reval = true;
		for (Condition c : conditions)
		{
			try{
				if (!c.passed(num)){
					reval = false;
				}
			}catch(ExpressionException e){
				msg += e.getMessage()+",";
			}
		}
		return reval;
	}


}
